<template>
    <div>
        <div class="head">
            <span class="iconfont icon-arrow-left-bold" @click="gotoUp"></span>
            <div class="title">收银台</div>
        </div>
        <div class="container">
            <div class="tab-box">
                <div class="tit">商品信息</div>
                <div class="item">
                    <div class="left">
                        <img src="http://h5.xiaomage.tech/static/img/default-vip.8b4e3275.png" alt="" />
                    </div>
                    <div class="right">
                        <div>{{ this.$route.query.goods_name }}</div>
                        <div>{{ this.$route.query.goods_label }}</div>
                        <div>￥{{ this.$route.query.goods_charge }}</div>
                    </div>
                </div>
            </div>
            <div class="promotioncode">
                <div>使用优惠码</div>
                <span class="iconfont icon-arrow-right-bold"></span>
            </div>
            <div class="farm">
                <div class="item">
                    <span class="iconfont icon-chongzhi"></span>
                    <div class="tit">{{ obj.name }}</div>
                    <div class="img">
                        <img
                            src=""
                            alt=""
                        />
                    </div>
                </div>
            </div>
            <div class="button">
                <div class="tit">
                    总计￥<span class="big">{{ this.$route.query.goods_charge }}</span>
                </div>
                <div class="btn" @click="gotoPay">立即支付</div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            obj: {},
            list: {},
        };
    },
    methods: {
        gotoUp() {
            this.$router.go(-1);
        },
        async gotoPay() {
            let pay = await this.$request.post("/api/v2/order/role", {
                role_id: this.$route.query.goods_id,
            });
            this.list = pay.data;
            this.$router.push({
                path: "/buyvip/pay",
                query: {
                    orderId: this.list.order_id,
                    price: this.list.charge,
                    payment: this.obj.sign,
                    type: "role",
                    id: this.list.user_id,
                },
            });
        },
    },
    async created() {
        let res = await this.$request.get("/api/v2/order/payments", {
            params: {
                scene: "h5",
            },
        });
        this.obj = res.data[0];
    },
};
</script>

<style lang="less" scoped>
.head {
    position: fixed;
    top: 0;
    width: 100%;
    height: 50px;
    background-color: #fff;
    z-index: 100;
    padding-left: 15px;
    padding-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f1f2f6;
    span {
        font-size: 19px;
        position: absolute;
        top: 50%;
        margin-top: -10px;
        left: 4%;
    }
    .title {
        flex: 1;
        font-size: 17px;
        font-weight: 500;
        text-align: center;
        color: #333;
        line-height: 22px;
        overflow: hidden;
    }
}
.container {
    padding-top: 50px;
    background: #f6f6f6;
    position: absolute;
    left: 0;
    top: 0;
    overflow-y: scroll;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    .tab-box {
        width: 100%;
        height: 164px;
        background: #fff;
        margin-top: 10px;
        padding: 15px;
        .tit {
            width: 100%;
            height: 14px;
            font-size: 14px;
            font-weight: 400;
            color: #333;
            line-height: 14px;
            margin-bottom: 30px;
        }
        .item {
            width: 100%;
            height: 75px;
            display: flex;
            flex-direction: row;
            .left {
                width: 100px;
                height: 75px;
                border-radius: 2px;
                margin-right: 15px;
                img {
                    width: 100%;
                    height: 100%;
                    border-radius: 2px;
                }
            }
            .right {
                width: 66%;
                height: 75px;
                display: flex;
                flex-direction: column;
                div:nth-child(1) {
                    width: 100%;
                    height: 15px;
                    font-size: 15px;
                    font-weight: 600;
                    color: #333;
                    line-height: 15px;
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    margin-top: 2px;
                    margin-bottom: 10px;
                }
                div:nth-child(2) {
                    height: 13px;
                    font-size: 13px;
                    font-weight: 400;
                    color: #ff4d4f;
                    line-height: 13px;
                    margin-bottom: 18px;
                }
                div:nth-child(3) {
                    height: 15px;
                    font-size: 15px;
                    font-weight: 600;
                    color: #fd3968;
                    line-height: 15px;
                }
            }
        }
    }
    .promotioncode {
        width: 100%;
        height: 57px;
        background: #fff;
        margin-top: 10px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-left: 15px;
        padding-right: 15px;
        div {
            display: inline-block;
            height: 15px;
            font-size: 15px;
            font-weight: 400;
            color: #333;
            line-height: 15px;
        }
        span {
            font-size: 19px;
        }
    }
    .farm {
        width: 100%;
        background: #fff;
        margin-top: 10px;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 30px 15px;
        .item {
            width: 100%;
            height: 30px;
            display: flex;
            flex-direction: row;
            align-items: center;
            position: relative;
            span {
                width: 30px;
                height: 30px;
                margin-right: 15px;
                font-size: 20px;
                color: #ff8b3f;
                display: flex;
                align-items: center;
            }
            .tit {
                height: 18px;
                font-size: 18px;
                font-weight: 400;
                color: #333;
                line-height: 18px;
            }
            .img {
                width: 24px;
                height: 24px;
                position: absolute;
                right: 0;
                top: 3px;
                img {
                    width: 100%;
                    height: 100%;
                }
            }
        }
    }
    .button {
        width: 100%;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 49px;
        background: #fff;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        .tit {
            height: 24px;
            font-size: 16px;
            font-weight: 500;
            color: #ff4d4f;
            line-height: 24px;
            margin-left: 15px;
            .big {
                font-size: 24px;
            }
        }
        .btn {
            width: 144px;
            height: 49px;
            background: #000;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            font-weight: 500;
            color: #fff;
        }
    }
}
</style>
